package com.ian.offer;

import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;

/**
 * @author zhangyaowen
 * @date 2021/2/25 10:09 下午
 */

/**
 *
 */
public class MaxProfit {

    public int maxProfit(int[] prices) {

        int min = Integer.MAX_VALUE;
        int res = 0;

        for (int i = 1; i < prices.length; i++) {
            if (prices[i]<min){
                min = prices[i];
            }else{
                if (prices[i] -min >res){
                    res = prices[i]-min;
                }
            }
        }



        return  0;

    }
}
